﻿Imports AugmentLib.Database
Imports System.Configuration.ConfigurationManager
Imports AugmentLib.WebComponent
Imports AugmentLib.InputOutput.Encryption

Partial Class UploadSearch
    Inherits System.Web.UI.Page

#Region " Properties "

    Public Property CurrentPage() As Integer
        Get
            'Looks for the current page in ViewState
            Dim objPage As Object = ViewState("_CurrentPage")
            If objPage Is Nothing Then
                Return 0
            Else
                'default to showing the first page
                Return CInt(objPage)
            End If
        End Get
        Set(ByVal value As Integer)
            ViewState("_CurrentPage") = value
        End Set
    End Property

    Public Property PageSize() As Integer
        Get
            'Looks for the current page in ViewState
            Dim objPageSize As Object = ViewState("_PageSize")
            If objPageSize Is Nothing Then
                Return 25
            Else
                'default to showing the first page
                Return CInt(objPageSize)
            End If
        End Get
        Set(ByVal value As Integer)
            ViewState("_PageSize") = value
        End Set
    End Property

#End Region

#Region " Paging and Page Size "

    Protected Sub lnkHead10Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead10Item.Click
        PageSize = 10
        LoadUpload()
    End Sub

    Protected Sub lnkHead25Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead25Item.Click
        PageSize = 25
        LoadUpload()
    End Sub

    Protected Sub lnkHead100Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead100Item.Click
        PageSize = 100
        'LoadUpload()
    End Sub

    Protected Sub lnkHead150Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead150Item.Click
        PageSize = 150
        LoadUpload()
    End Sub

    Protected Sub lnkFoot10Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot10Item.Click
        PageSize = 10
        'LoadUpload()
    End Sub

    Protected Sub lnkFoot25Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot25Item.Click
        PageSize = 25
        LoadUpload()
    End Sub

    Protected Sub lnkFoot100Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot100Item.Click
        PageSize = 100
        LoadUpload()
    End Sub

    Protected Sub lnkFoot150Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot150Item.Click
        PageSize = 150
        LoadUpload()
    End Sub

    Protected Sub btnMoveFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveFirst.Click
        CurrentPage = 0
        txtPageNo.Text = CurrentPage + 1
        LoadUpload()
    End Sub

    Protected Sub btnPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        If CurrentPage > 0 Then
            CurrentPage = CurrentPage - 1
            txtPageNo.Text = CurrentPage + 1
            LoadUpload()
        End If
    End Sub

    Protected Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGo.Click
        If CInt(txtPageNo.Text < 1) Then
            txtPageNo.Text = 1
        End If

        If CInt(txtPageNo.Text > CInt(lblMaxPageCount.Text)) Then
            txtPageNo.Text = CInt(lblMaxPageCount.Text) + 1
        End If

        CurrentPage = CInt(txtPageNo.Text) - 1
        LoadUpload()

    End Sub

    Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If CurrentPage < CInt(lblMaxPageCount.Text) Then
            CurrentPage = CurrentPage + 1
            txtPageNo.Text = CurrentPage + 1
            LoadUpload()
        End If
    End Sub

    Protected Sub btnMoveLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveLast.Click
        CurrentPage = CInt(lblMaxPageCount.Text)
        txtPageNo.Text = CurrentPage + 1
        LoadUpload()
    End Sub

#End Region

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        CurrentPage = 0
        txtPageNo.Text = CurrentPage + 1
        Session("anchor1") = ""
        LoadUpload()
    End Sub

    Private Sub LoadUpload()
        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable
        divError.Visible = False
        Try
            objDB.OpenConnection()

            Dim UnitNo, Address, LelongTipCode, PropertyType, AuctionVenue, Bank, LandAreaMin, LandAreaMax, PriceMin, PriceMax, AuctionDateMin, AuctionDateMax, RemindDateMin, RemindDateMax As String

            If txtUnitNo.Text <> String.Empty Then
                UnitNo = " AND UnitNo LIKE @UnitNo"
                objDB.AddParameter("UnitNo", Data.SqlDbType.NVarChar, "%" & txtUnitNo.Text.Trim & "%")
            Else
                UnitNo = String.Empty
            End If

            If txtAddress.Text <> String.Empty Then
                Address = " AND Address LIKE @Address"
                '" AND Alamat LIKE '%" + txtAlamat.Text.Replace(",", "%' AND [Title] LIKE '%") + "%'"
                objDB.AddParameter("Address", Data.SqlDbType.NVarChar, "%" & txtAddress.Text.Trim & "%")
            Else
                Address = String.Empty
            End If

            If txtLelongTipCode.Text <> String.Empty Then
                LelongTipCode = " AND LelongTipCode LIKE @LelongTipCode"
                objDB.AddParameter("LelongTipCode", Data.SqlDbType.NVarChar, "%" & txtLelongTipCode.Text.Trim & "%")
            Else
                LelongTipCode = String.Empty
            End If

            If ddlType.SelectedValue <> "" Then
                PropertyType = " AND Type LIKE @Type"
                objDB.AddParameter("Type", Data.SqlDbType.NVarChar, "%" & ddlType.SelectedItem.Text.Trim & "%")
            Else
                PropertyType = String.Empty
            End If

            If txtAuctionVenue.Text <> String.Empty Then
                AuctionVenue = " AND AuctionVenue LIKE @AuctionVenue"
                objDB.AddParameter("AuctionVenue", Data.SqlDbType.NVarChar, "%" & txtAuctionVenue.Text.Trim & "%")
            Else
                AuctionVenue = String.Empty
            End If

            If ddlBank.SelectedValue <> String.Empty Then
                Bank = " AND Bank LIKE @Bank"
                objDB.AddParameter("Bank", Data.SqlDbType.NVarChar, "%" & ddlBank.SelectedItem.Text.Trim & "%")
            Else
                Bank = String.Empty
            End If

            If txtLandAreaMin.Text.Trim <> String.Empty Then
                LandAreaMin = " AND LandArea >= @LandAreaMin"
                objDB.AddParameter("LandAreaMin", Data.SqlDbType.BigInt, txtLandAreaMin.Text.Trim)
            Else
                LandAreaMin = String.Empty
            End If

            If txtLandAreaMax.Text.Trim <> String.Empty Then
                LandAreaMax = " AND LandArea <= @LandAreaMax"
                objDB.AddParameter("LandAreaMax", Data.SqlDbType.Decimal, txtLandAreaMax.Text.Trim)
            Else
                LandAreaMax = String.Empty
            End If

            If txtPriceMin.Text.Trim <> String.Empty Then
                PriceMin = " AND Price >= @PriceMin"
                objDB.AddParameter("PriceMin", Data.SqlDbType.Decimal, txtPriceMin.Text.Trim)
            Else
                PriceMin = String.Empty
            End If

            If txtPriceMax.Text.Trim <> String.Empty Then
                PriceMax = " AND Price <= @PriceMax"
                objDB.AddParameter("PriceMax", Data.SqlDbType.Decimal, txtPriceMax.Text.Trim)
            Else
                PriceMax = String.Empty
            End If

            If txtAuctionDateMin.Text.Trim <> String.Empty Then
                AuctionDateMin = " AND AuctionDate >= @AuctionDateMin"
                objDB.AddParameter("AuctionDateMin", Data.SqlDbType.Date, txtAuctionDateMin.Text.Trim)
            Else
                AuctionDateMin = String.Empty
            End If

            If txtAuctionDateMax.Text.Trim <> String.Empty Then
                AuctionDateMax = " AND AuctionDate <= @AuctionDateMax"
                objDB.AddParameter("AuctionDateMax", Data.SqlDbType.Date, txtAuctionDateMax.Text.Trim)
            Else
                AuctionDateMax = String.Empty
            End If

            If txtRemindDateMin.Text.Trim <> String.Empty Then
                RemindDateMin = " AND RemindDate >= @RemindDateMin"
                objDB.AddParameter("RemindDateMin", Data.SqlDbType.Date, txtRemindDateMin.Text.Trim)
            Else
                RemindDateMin = String.Empty
            End If

            If txtRemindDateMax.Text.Trim <> String.Empty Then
                RemindDateMax = " AND RemindDate <= @RemindDateMax"
                objDB.AddParameter("RemindDateMax", Data.SqlDbType.Date, txtRemindDateMax.Text.Trim)
            Else
                RemindDateMax = String.Empty
            End If

            objDB.AddParameter("StatusDelete", Data.SqlDbType.TinyInt, ddlStatusDelete.SelectedValue)

            objDB.dbVariable.SQLString = "SELECT a.LelongId, a.LelongTipCode, a.UnitNo, a.Address,a.Type,a.AuctionVenue, a.Bank, a.LandArea, a.Price, a.AuctionDate, a.RemindDate,b.username as AgentID, " & _
                                        "AuctionTime,  Auctioneer from AW_Lelong a " & _
                                        "LEFT JOIN AW_STAFF b ON a.AgentID = b.StaffId " & _
                                        "WHERE a.StatusDelete = @StatusDelete " &
                                        UnitNo & Address & LelongTipCode & PropertyType & AuctionVenue & Bank & LandAreaMin & LandAreaMax & PriceMin & PriceMax & AuctionDateMin & AuctionDateMax & RemindDateMin & RemindDateMax &
                                        lblhidSortType.Text

            objDB.FillData(TempDT, "AW_Lelong", Database.SQLCommandType.NormalString)

            objDB.CloseConnection()

            'Creating a Paged Datasouce
            Dim objPaged As New PagedDataSource
            objPaged.DataSource = TempDT.DefaultView
            objPaged.AllowPaging = True
            objPaged.PageSize = PageSize
            objPaged.CurrentPageIndex = CurrentPage

            lblHeadNoOfItem.Text = TempDT.Rows.Count
            lblFootNoOfItem.Text = TempDT.Rows.Count

            repUpload.DataSource = objPaged
            repUpload.DataBind()

            lblMaxPageCount.Text = objPaged.PageCount - 1
            lblTotalPage.Text = " of " & objPaged.PageCount

        Catch ex As Exception
            divError.Visible = True
            lblMsgError.Text = ex.Message.ToString
        Finally
            If (objDB IsNot Nothing) Then
                objDB.CloseConnection()
            End If
        End Try
    End Sub

    Private Function SortType(ByVal strSortType As String) As String
        Dim strSort As String
        If Right(strSortType, 1) = "▼" Then
            strSort = "ASC"
        Else
            strSort = "DESC"
        End If
        Return strSort
    End Function

    Protected Sub lnkUnitNo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkUnitNo.Click
        If lnkUnitNo.Text = "UnitNo▼" Then
            lnkUnitNo.Text = "UnitNo▲"
        Else
            lnkUnitNo.Text = "UnitNo▼"
        End If

        lblhidSortType.Text = " ORDER BY UnitNo " & SortType(lnkUnitNo.Text) & _
                            ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                            ", RemindDate " & SortType(lnkRemindDate.Text) & _
                            ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkAddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAddress.Click
        If lnkAddress.Text = "Address▼" Then
            lnkAddress.Text = "Address▲"
        Else
            lnkAddress.Text = "Address▼"
        End If

        lblhidSortType.Text = " ORDER BY Address " & SortType(lnkAddress.Text) & _
                            ", UnitNo " & SortType(lnkUnitNo.Text) & _
                            ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                            ", RemindDate " & SortType(lnkRemindDate.Text) 
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkPropertyType_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkPropertyType.Click
        If lnkPropertyType.Text = "Type▼" Then
            lnkPropertyType.Text = "Type▲"
        Else
            lnkPropertyType.Text = "Type▼"
        End If

        lblhidSortType.Text = " ORDER BY Type " & SortType(lnkPropertyType.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkVenue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkVenue.Click
        If lnkVenue.Text = "AuctionVenue▼" Then
            lnkVenue.Text = "AuctionVenue▲"
        Else
            lnkVenue.Text = "AuctionVenue▼"
        End If

        lblhidSortType.Text = " ORDER BY AuctionVenue " & SortType(lnkVenue.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkBank_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkBank.Click
        If lnkBank.Text = "Bank▼" Then
            lnkBank.Text = "Bank▲"
        Else
            lnkBank.Text = "Bank▼"
        End If

        lblhidSortType.Text = " ORDER BY Bank " & SortType(lnkBank.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkLandArea_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLandArea.Click
        If lnkLandArea.Text = "LandArea▼" Then
            lnkLandArea.Text = "LandArea▲"
        Else
            lnkLandArea.Text = "LandArea▼"
        End If

        lblhidSortType.Text = " ORDER BY LandArea " & SortType(lnkLandArea.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkPrice_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkPrice.Click
        If lnkPrice.Text = "Price▼" Then
            lnkPrice.Text = "Price▲"
        Else
            lnkPrice.Text = "Price▼"
        End If

        lblhidSortType.Text = " ORDER BY Price " & SortType(lnkPrice.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkAuctionDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAuctionDate.Click
        If lnkAuctionDate.Text = "Auction Date▼" Then
            lnkAuctionDate.Text = "Auction Date▲"
        Else
            lnkAuctionDate.Text = "Auction Date▼"
        End If

        lblhidSortType.Text = " ORDER BY AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)

        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkRemindDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRemindDate.Click
        If lnkRemindDate.Text = "Reminder Date▼" Then
            lnkRemindDate.Text = "Reminder Date▲"
        Else
            lnkRemindDate.Text = "Reminder Date▼"
        End If

        lblhidSortType.Text = " ORDER BY RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkAgent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAgent.Click
        If lnkAgent.Text = "Agent▼" Then
            lnkAgent.Text = "Agent▲"
        Else
            lnkAgent.Text = "Agent▼"
        End If

        lblhidSortType.Text = " ORDER BY AgentID " & SortType(lnkAgent.Text) & _
                              ", AuctionDate " & SortType(lnkAuctionDate.Text) & _
                              ", RemindDate " & SortType(lnkRemindDate.Text) & _
                              ", UnitNo " & SortType(lnkUnitNo.Text) & _
                              ", Address " & SortType(lnkAddress.Text)
        btnSearch_Click(sender, e)
    End Sub



    Protected Sub repUpload_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repUpload.ItemCommand
        If e.CommandName = "ViewList" Then
            'Edited by minginn - To allow user to go back to the search page with same search selection
            '1-Back Page
            '2-Page Size
            '3-Current Page

            Dim strBack As String
            strBack = "Auction.aspx" & "ڡ" & PageSize & "ڡ" & CurrentPage & "ڡ" & txtUnitNo.Text.Trim & "ڡ" & _
                    txtAddress.Text.Trim & "ڡ" & txtLelongTipCode.Text.Trim & "ڡ" & ddlType.SelectedValue.Trim & "ڡ" & txtAuctionVenue.Text.Trim & "ڡ" & _
                    ddlBank.SelectedValue.Trim & "ڡ" & txtLandAreaMin.Text.Trim & "ڡ" & txtLandAreaMax.Text.Trim & "ڡ" & txtPriceMin.Text.Trim & _
                    "ڡ" & txtPriceMax.Text.Trim & "ڡ" & txtAuctionDateMin.Text.Trim & "ڡ" & txtAuctionDateMax.Text.Trim & "ڡ" & txtRemindDateMin.Text.Trim & _
                    "ڡ" & txtRemindDateMax.Text.Trim & "ڡ" & ddlStatusDelete.SelectedValue.Trim
            Session.Add("Back", strBack)
            'Response.Redirect("AuctionEntry.aspx?id=" & SymmetricEncryptToHex(e.CommandArgument, "augment"))
            Response.Redirect("AuctionEntry.aspx?id=" & e.CommandArgument)
        End If
        If e.CommandName.ToUpper = "DELETEITEM" Then

            'Begin Delete
            Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
            Try
                objDB.OpenConnection()
                objDB.dbVariable.SQLString = "UPDATE AW_Lelong SET StatusDelete=1 WHERE LelongId=@LelongId"
                objDB.AddParameter("LelongId", Data.SqlDbType.UniqueIdentifier, New Guid(CType(repUpload.Items(e.CommandArgument).FindControl("lblRepLelongId"), Label).Text))
                objDB.ExecuteQuery()
                objDB.CloseConnection()
                lblMsgSuccessful.Text = "Entry Deleted"
                lblMsgSuccessful.Visible = True
                divSuccessful.Visible = True
                LoadUpload()
            Catch ex As Exception
            divError.Visible = True
                lblMsgError.Text = ex.Message.ToString
            Finally
                If (objDB IsNot Nothing) Then
                    objDB.CloseConnection()
                End If
            End Try
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session.Item("StaffId") Is Nothing Then
            Response.Redirect("default.aspx")
        End If

        'Edited by minginn @ 27/6/2011 - to load the same search when user back from other page
        If Not Session("Back") Is Nothing Then
            Dim strBack As String = Session("Back").ToString
            Dim arr() As String = strBack.Split("ڡ")
            '1-Back Page
            '2-Page Size
            '3-Current Page
            '4-UnitNo
            '5-Address
            '6-Type
            '7-Venue
            '8-Bank
            '9-Trkh Penilaian
            '10-Price
            '11-Auction Date
            '12-Alamat
            '13-Agent

            If arr(0).ToString.Contains("Auction.aspx") Then
                If arr.Length > 3 Then
                    PageSize = CInt(arr(1).ToString)
                    CurrentPage = CInt(arr(2).ToString)
                    txtUnitNo.Text = arr(3).ToString
                    txtAddress.Text = arr(4).ToString
                    txtLelongTipCode.Text = arr(5).ToString
                    ddlType.SelectedValue = arr(6).ToString
                    txtAuctionVenue.Text = arr(7).ToString
                    ddlBank.SelectedValue = arr(8).ToString
                    txtLandAreaMin.Text = arr(9).ToString
                    txtLandAreaMax.Text = arr(10).ToString
                    txtPriceMin.Text = arr(11).ToString
                    txtPriceMax.Text = arr(12).ToString
                    txtAuctionDateMin.Text = arr(13).ToString
                    txtAuctionDateMax.Text = arr(14).ToString
                    txtRemindDateMin.Text = arr(15).ToString
                    txtRemindDateMax.Text = arr(16).ToString
                    ddlStatusDelete.SelectedValue = arr(17).ToString
                End If
                Session.Remove("Back")
                LoadUpload()

            Else
                Session.Remove("Back")
            End If
        Else
            If Not Page.IsPostBack Then

                lblStaffUID.Text = Session.Item("StaffId").ToString
                lblStaffType.Text = Session.Item("StaffType").ToString
                lnkAuctionDate_Click(sender, e)
            End If
        End If

        If Not Page.IsPostBack Then

            lblStaffUID.Text = Session.Item("StaffId").ToString
            lblStaffType.Text = Session.Item("StaffType").ToString

        End If
    End Sub

    Protected Sub btnResetSearchFilter_Click(sender As Object, e As EventArgs) Handles btnResetSearchFilter.Click

        CurrentPage = 0
        txtUnitNo.Text = ""
        txtAddress.Text = ""
        txtLelongTipCode.Text = ""
        txtAuctionVenue.Text = ""
        txtLandAreaMin.Text = ""
        txtLandAreaMax.Text = ""
        txtPriceMin.Text = ""
        txtPriceMax.Text = ""
        txtAuctionDateMin.Text = ""
        txtAuctionDateMax.Text = ""
        txtRemindDateMin.Text = ""
        txtRemindDateMax.Text = ""
        ddlBank.SelectedIndex = 0
        ddlType.SelectedIndex = 0
        ddlStatusDelete.SelectedIndex = 0
    End Sub
End Class
